/*
░██████╗████████╗███████╗██╗░░░██╗███████╗ ██████╗░░█████╗░░██████╗░███████╗██████╗░░██████╗
██╔════╝╚══██╔══╝██╔════╝██║░░░██║██╔════╝ ██╔══██╗██╔══██╗██╔════╝░██╔════╝██╔══██╗██╔════╝
╚█████╗░░░░██║░░░█████╗░░╚██╗░██╔╝█████╗░░ ██████╔╝██║░░██║██║░░██╗░█████╗░░██████╔╝╚█████╗░
░╚═══██╗░░░██║░░░██╔══╝░░░╚████╔╝░██╔══╝░░ ██╔══██╗██║░░██║██║░░╚██╗██╔══╝░░██╔══██╗░╚═══██╗
██████╔╝░░░██║░░░███████╗░░╚██╔╝░░███████╗ ██║░░██║╚█████╔╝╚██████╔╝███████╗██║░░██║██████╔╝
╚═════╝░░░░╚═╝░░░╚══════╝░░░╚═╝░░░╚══════╝ ╚═╝░░╚═╝░╚════╝░░╚═════╝░╚══════╝╚═╝░░╚═╝╚═════╝░
*/
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7;
#define int long long
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define vpii vector<pair<int,int>>
#define pb push_back
#define fin0 for(int i=0;i<n;i++)
#define fin1 for(int i=1;i<=n;i++)
#define test int t;cin>>t;while(t--)
// binary multiply (iterative version)
ll bmul(ll a, ll b)
{ int ans=0;
while(b>0)
{ if(b&1) ans= (ans+a)%M;
a= (a+a)%M;
b=b>>1;
}return ans;
}
// gcd function
int gcd(int small, int big)
{
if(big%small==0)return small;
else return gcd(big%small,small);
}
// binary exponentiation (recursive version)
ll bxp(ll a, ll b)
{
if (b==0) return 1;
ll res=bxp(a,b/2);
if(b&1) return (a*bmul(res,res))%M;
else return bmul(res,res);
}
ll mod( ll a)
{
if(a>0)return a;
else return -1*a;
}
/* ---------------------- (Main) ---------------------- */
signed main()
{
test
{
int k,x;cin>>k>>x;
if(k*k<=x)
{
cout<<2*k-1<<endl;continue;
}
int m=0;
if(x<=(k*k +k)/2)
{
int r=(sqrtl(8*x+1)-1)/2;
if(x==(r*(r+1))/2);
else r++;
m=r;
}
else
{
x=x-k*(k+1)/2;
x=k*(k-1)/2-x+1;
int r=(sqrtl(8*x+1)-1)/2;
if(x==(r*(r+1))/2);
else r++;
m+= 2*k-r;
}
cout<<m<<endl;
}
}
664A - Complicated GCD | 1635D - Infinite Set |
1462A - Favorite Sequence | 1445B - Elimination |
1656C - Make Equal With Mod | 567A - Lineland Mail |
1553A - Digits Sum | 1359B - New Theatre Square |
766A - Mahmoud and Longest Uncommon Subsequence | 701B - Cells Not Under Attack |
702A - Maximum Increase | 1656D - K-good |
1426A - Floor Number | 876A - Trip For Meal |
1326B - Maximums | 1635C - Differential Sorting |
961A - Tetris | 1635B - Avoid Local Maximums |
20A - BerOS file system | 1637A - Sorting Parts |
509A - Maximum in Table | 1647C - Madoka and Childish Pranks |
689B - Mike and Shortcuts | 379B - New Year Present |
1498A - GCD Sum | 1277C - As Simple as One and Two |
1301A - Three Strings | 460A - Vasya and Socks |
1624C - Division by Two and Permutation | 1288A - Deadline |